package com.keepercloud.qqchat.service.impl;

import com.keepercloud.qqchat.entity.User;
import com.keepercloud.qqchat.repository.UserRepository;
import com.keepercloud.qqchat.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author liyk
 * @date 2019/2/12
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UserServiceImpl implements UserService {

    final
    private UserRepository userRepository;

    @Autowired
    public UserServiceImpl(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Override
    public User findByUsername(String username) {
        return userRepository.findByUsername(username);
    }

    @Override
    public void save(User user) {
        userRepository.save(user);
    }

    @Override
    public List<String> getRoleList(String username) {
        return userRepository.getRoleList(username);
    }
}
